#!/bin/bash
# translates a fasta file to a tab file.

# parameters.
fasta_file=$1
tab_file=$2

# execute awk.
awk '
BEGIN {
	head = ""
	seq = ""
}
{
	if( substr($1,0,1) == ">" ){
		if( head != "" ){
			printf("%s\t%s\n",head,seq);
		}
		gsub(">","");
		head = $0;
		seq = ""
	} else {
		gsub(/^[ \t]+|[ \t]+$/,"",$0);
		seq = seq$0
	}
}' $fasta_file > $tab_file
